//
//  DawnGridCell.swift
//  Test
//
//  Created by cuicheng on 2021/8/25.
//

import UIKit

class DawnGridCell: UICollectionViewCell {
    var ivSize: CGFloat = 25.adapter
    var mod: DawnGridModel? {
        didSet{
            iv.image = UIImage(named: mod?.icon ?? "")
            lbl.text = mod?.name
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        _init()
    }
    
    private func _init() {
        iv = {
            let v = UIImageView()
            v.contentMode = .scaleAspectFit
            return v
        }()
        
        lbl = {
            let lbl = UILabel()
            lbl.textAlignment = .center
            lbl.textColor = .title
            lbl.font = .font(13)
            return lbl
        }()
        da.addSubviews(sub: [iv, lbl])
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        iv.centerY((bounds.height-25)/2).width_height(ivSize).centerX(bounds.width/2)
        lbl.left_right(contentView).top(iv.frame.maxY+5).height(20)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private var iv: UIImageView!
    private var lbl: UILabel!
    
}
